<?php
namespace app\custom\controller;
use app\rbac\model\AdminM;
use app\custom\model\MsgM;
use think\Db;
use think\Session;
use app\base\controller\Base;

class Msg extends Base
{
    public function __construct()
    {
        parent::__construct();
    }


    /**
     * 获取全部数据
     * @return mixed
     */
    public function lst()
    {

        $model = new MsgM();
        $data = $model->lst(15);
        // 获取分页显示
        $page = $data->render();
        $this->assign(array(
            '_page_title'=>'留言列表',
            '_page_title_english'=>'Msg list',
            '_btn_title'=>'留言列表',
            '_btn_link'=>url('lst'),
            '_page_ico'=>'iconfa-headphones',
            'data'=>$data,
            'page'=>$page,
        ));
        return $this->fetch();
    }


    /**
     * 删除数据
     * @param $id
     */
    public function del()
    {
        $id = $this->request->post('id');
        $model = new MsgM();
        $model->del($id);
        return json(['code'=>$model->code,'msg'=>$model->msg]);
    }

    /**
     * 删除数据
     * @param $id
     */
    public function handle()
    {
        $id = $this->request->post('id');
        $model = new MsgM();
        $model->handle($id);
        return json(['code'=>$model->code,'msg'=>$model->msg]);
    }
}
